<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>删除页面上的所有p元素</title>
    <script>
        function delp() {
            var ps = document.getElementsByTagName('p')
            console.log(ps)
            for (var i = 0; i <= ps.length;) {
                ps[i].parentNode.removeChild(ps[i])
            }
        }
    </script>
</head>

<body>
    <p>什么是JavaScript</p>
    <p>JavaScript是一门功能强大的编程语言</p>
    <h1>一起来学习JavaScript程序设计</h1>
    <hr>
    <p>JavaScript的发展历史</p>
    <input type="button" value="删除所有p元素" onclick="delp()">
</body>

</html>